<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8" />
    <title>采集壁纸</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../../../css/font.css" />
    <link rel="stylesheet" href="../../../css/xadmin.css" />
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/checklogin.js"></script>
    <!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    <style>
        .cj {
            display: flex;
            justify-content: space-around;
            margin-top: 20px;
        }
        
        .code {
            width: 85%;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <form class="layui-form" action="">
        <div class="layui-inline cj">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <select name="caiji_yuan" lay-verify="required">
                        <option value="">采集源</option>
                        <option value="xiaoquan">小圈壁纸</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="caiji_cat" lay-verify="required">
                        <option value="">采集分类</option>
                        <option value="xjj">小姐姐</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="type" lay-verify="required">
                        <option value="">采集方式</option>
                        <option value="new">最新</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="release_cat" lay-verify="required" lay-search="">
                        <option value="">发布分类</option>
                        <option value="xjj">小姐姐</option>
                        <option value="xgg">小哥哥</option>
                        <option value="dm">动漫</option>
                    </select>
                </div>
                <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="caiji">
                    立即采集
                </button>
            </div>
        </div>
    </form>
    <div class="code">
        <pre class="layui-code" lay-title="运行日志" lay-skin="notepad" lay-height="550px">
等待执行...</pre>
    </div>
</body>
<script>
    // 开启 code
    layui.use("code", function() {
        layui.code();
    });

    // 采集
    layui.use("form", function() {
        var form = layui.form;
        form.on("submit(caiji)", function(data) {
            let val = data.field;
            ajaxHttp({
                url: "http://localhost:3000/admin/wallpaper/caiji",
                type: "get",
                data: {
                    caiji_cat: val.caiji_cat,
                    release_cat: val.release_cat,
                    caiji_yuan: val.caiji_yuan,
                    type: val.type
                },
                success: function(result) {
                    for (let i = 0; i < result.data.length; i++) {
                        let text = `<li>${result.msg}：${result.data[i].src}</li>`;
                        $(".layui-code-ol").append(text);
                    }
                    layer.msg(
                        "采集成功", {
                            icon: 1,
                            time: 2000,
                        },
                        function() {
                            location.reload();
                        }
                    );
                },
            });
            return false;
        });
    });
</script>

</html>